package com.design.flyweight.game;

// 玩家类
class Player {
    private String name;
    private Equipment weapon;
    private Equipment armor;

    public Player(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    // 装备武器
    public void equipWeapon(String weaponName) {
        EquipmentFactory equipmentFactory = new EquipmentFactory();
        weapon = equipmentFactory.getEquipment("Weapon", weaponName);
        weapon.use(this);
    }

    // 装备护甲
    public void equipArmor(String armorName) {
        EquipmentFactory equipmentFactory = new EquipmentFactory();
        armor = equipmentFactory.getEquipment("Armor", armorName);
        armor.use(this);
    }
}
